// self test
#ifdef sm
struct {
	char s[4];
	uint8_t dcb_flags;
	uint8_t scroll_top;
} zz;
#else
void zz_on_keydown(uint8_t key) {
	register uint8_t i, j;
	/*if (key == 29) {
		xx_on_init();
		return;
	}*/
	led_inv = !led_inv;
	switch (key) {
	case 0:
		sm.zz.dcb_flags ^= 0x04;
		lcd_command(0x30);
		lcd_command(sm.zz.dcb_flags);
		break;
	case 1:
		sm.zz.dcb_flags ^= 0x02;
		lcd_command(0x30);
		lcd_command(sm.zz.dcb_flags);
		break;
	case 2:
		sm.zz.dcb_flags ^= 0x01;
		lcd_command(0x30);
		lcd_command(sm.zz.dcb_flags);
		break;
	}
	lcd_flush();
}

void zz_on_init(void) {
	lcd_clear_button_text();
	lcd_set_button_text(29, L"~");
	on_keydown = zz_on_keydown;
	sm.zz.dcb_flags = 0x0c;
	sm.zz.scroll_top = 0;
	draw_text_line(0,
		0xa3, 'T', 0xa3, 'e', 0xa3, 's', 0xa3, 't',
		'L', '0', ' ', ' ', ' ', ' ', ' ', ' '
	);
	draw_text_line(1,
		0xa3, 'T', 0xa3, 'e', 0xa3, 's', 0xa3, 't',
		' ', ' ', 'L', '1', ' ', ' ', ' ', ' '
	);
	draw_text_line(2,
		0xa3, 'T', 0xa3, 'e', 0xa3, 's', 0xa3, 't',
		' ', ' ', ' ', ' ', 'L', '2', ' ', ' '
	);
	draw_text_line(3,
		0xa3, 'T', 0xa3, 'e', 0xa3, 's', 0xa3, 't',
		' ', ' ', ' ', ' ', ' ', ' ', 'L', '3'
	);
	lcd_set_text((char xdata*) dm.t.t);
	lcd_flush();
}
#endif
